package neuron.library.ga.common;

import java.util.ArrayList;

import neuron.library.ga.crossover.CrossoverStrategy;
import neuron.library.ga.mutation.MutationStrategy;
import neuron.library.ga.replication.ReplicationStrategy;
import neuron.library.ga.selection.SelectionStrategy;
import neuron.library.ga.tuner.AbstractTuner;
import neuron.library.ga.observer.AbstractObserver;

/*
 * TODO: Comment!!
 */
public class GMConfiguration {
	
	
	/*
	 * Instance of crossover strategy.
	 */
	private CrossoverStrategy crossover;
	
	/*
	 * Instance of replication strategy.
	 */
	private ReplicationStrategy replication;
	
	/*
	 * Instance of mutation strategy.
	 */
	private MutationStrategy mutation;
	
	/*
	 * Instance of selection strategy.
	 */
	private SelectionStrategy selection;
	
	/*
	 * Instance of selection strategy.
	 */
	private AbstractFitness fitness;
	
    /*
     * Tuner instance.
     */
	private AbstractTuner tuner;
	
	/*
	 * Size of population.
	 */
    private int population_size;
    
    /*
     * TODO: Comment
     */
    private ArrayList<AbstractObserver> observers;
    
    /*
     * Chromosome factory.
     */
    private ChromosomeAbstractFactory chromosomeFactory;
	
    /*
     * TODO: Comment
     */
    private boolean stopped;
    
    /*
     * Constructor of conficuration class.
     */
	public GMConfiguration(){
		observers = new ArrayList<AbstractObserver>();
		chromosomeFactory = null;
		population_size = 100;
		replication = null;
		crossover = null;
		mutation = null;
		selection = null;
		fitness = null;
		tuner = null;
		stopped = false;
	}
    
  
    /*
     * Setter and Getter for crossover field.
     */
    public void setCrossover(CrossoverStrategy crossover) {
    	this.crossover = crossover;
    }
    public CrossoverStrategy getCrossover() {
    	return crossover;
    }

    /*
     * Setter and Getter for replication field.
     */
    public void setReplication(ReplicationStrategy replication) {
    	this.replication = replication;
    }
    public ReplicationStrategy getReplication() {
    	return replication;
    }
    
    /*
     * Setter and Getter for mutation field.
     */
    public void setMutation(MutationStrategy mutation) {
    	this.mutation = mutation;
    }
    public MutationStrategy getMutation() {
    	return mutation;
    }
    
    /*
     * Setter and Getter for selection field.
     */
    public void setSelection(SelectionStrategy selection) {
    	this.selection = selection;
    }
    public SelectionStrategy getSelection() {
    	return selection;
    }
    
    /*
     * Setter and Getter for fitness field.
     */
    public void setFitness(AbstractFitness fitness) {
    	this.fitness = fitness;
    }
    public AbstractFitness getFitness() {
    	return fitness;
    }
    
    /*
     * Setter and Getter for tuner field.
     */
    public void setTuner(AbstractTuner tuner) {
    	this.tuner = tuner;
    }
    public AbstractTuner getTuner() {
    	return tuner;
    }
    
    /*
     * Setter and Getter for population field.
     */
    public void setPopulatonSize(int population_size){
    	this.population_size = population_size;
    }
    public int getPopulatonSize(){
    	return population_size;
    }
    
    /*
     * Setter and Getter for observers list.
     */
    public void registerObserver(AbstractObserver obs) {
    	observers.add(obs);
    }
    public void unregisterObserver(AbstractObserver obs) {
    	observers.remove(obs);
    }
    public ArrayList<AbstractObserver> getObserversList() {
    	return observers;
    }
    
    /*
     * Setter and Getter for chromosome factory.
     */
    public void setChromosomeFactory(ChromosomeAbstractFactory chromosomeFactory) {
    	this.chromosomeFactory = chromosomeFactory;    	
    }
    public ChromosomeAbstractFactory getChromosomeFactory() {
    	return chromosomeFactory;
    }
    
    /*
     * TODO: Comment!
     */
    public void stopGeneticMachine() {
    	stopped = true;
    }
    
    /*
     * TODO: Comment!
     */
    public boolean isStopped() {
    	return stopped;
    }
}
